<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>vuex流程</title>
    </head>
    <body>
        <div id="app">
            {{$store.state.count}}
            <button @click="change">修改 state的值</button>
        </div>
        <script src="../js/vue.js"></script>
        <script src="../js/vuex.js"></script>
        <script>
            let store = new Vuex.Store({
                state: {
                    count:10
                },
                mutations:{
                    changeCount(state){
                        state.count++;
                    }
                }
            })
            var vm = new Vue({
                el: '#app',
                data: {
                },
                //4.注册
                store,
                methods: {
                    change() {
                        //this.$store.state.count++; 在vuex中不能直接给 store中的state的值进行更改，不能直接跟踪状态值

                        //提交mutation
                        this.$store.commit("changeCount");
                    }
                }
            });
            console.log(vm);
        </script>
    </body>
</html>